\(\int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+b \tan (c+d x))^4} \, dx\) [292]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F(-2)]
   Maxima [B] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 31, antiderivative size = 261 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+b \tan (c+d x))^4} \, dx=-\frac {\left (a^4 A-6 a^2 A b^2+A b^4+4 a^3 b B-4 a b^3 B\right ) x}{\left (a^2+b^2\right )^4}-\frac {\left (4 a^3 A b-4 a A b^3-a^4 B+6 a^2 b^2 B-b^4 B\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{\left (a^2+b^2\right )^4 d}-\frac {a^2 (A b-a B)}{3 b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))^3}+\frac {a \left (2 A b^3-a \left (a^2+3 b^2\right ) B\right )}{2 b^2 \left (a^2+b^2\right )^2 d (a+b \tan (c+d x))^2}+\frac {3 a^2 A b-A b^3-a^3 B+3 a b^2 B}{\left (a^2+b^2\right )^3 d (a+b \tan (c+d x))} \]

[Out]

-(A*a^4-6*A*a^2*b^2+A*b^4+4*B*a^3*b-4*B*a*b^3)*x/(a^2+b^2)^4-(4*A*a^3*b-4*A*a*b^3-B*a^4+6*B*a^2*b^2-B*b^4)*ln(
a*cos(d*x+c)+b*sin(d*x+c))/(a^2+b^2)^4/d-1/3*a^2*(A*b-B*a)/b^2/(a^2+b^2)/d/(a+b*tan(d*x+c))^3+1/2*a*(2*A*b^3-a
*(a^2+3*b^2)*B)/b^2/(a^2+b^2)^2/d/(a+b*tan(d*x+c))^2+(3*A*a^2*b-A*b^3-B*a^3+3*B*a*b^2)/(a^2+b^2)^3/d/(a+b*tan(
d*x+c))

Rubi [A] (verified)

Time = 0.58 (sec) , antiderivative size = 261, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.161, Rules used = {3685, 3709, 3610, 3612, 3611} \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+b \tan (c+d x))^4} \, dx=-\frac {a^2 (A b-a B)}{3 b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))^3}+\frac {a \left (2 A b^3-a B \left (a^2+3 b^2\right )\right )}{2 b^2 d \left (a^2+b^2\right )^2 (a+b \tan (c+d x))^2}+\frac {a^3 (-B)+3 a^2 A b+3 a b^2 B-A b^3}{d \left (a^2+b^2\right )^3 (a+b \tan (c+d x))}-\frac {\left (a^4 (-B)+4 a^3 A b+6 a^2 b^2 B-4 a A b^3-b^4 B\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{d \left (a^2+b^2\right )^4}-\frac {x \left (a^4 A+4 a^3 b B-6 a^2 A b^2-4 a b^3 B+A b^4\right )}{\left (a^2+b^2\right )^4} \]

[In]

Int[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + b*Tan[c + d*x])^4,x]

[Out]

-(((a^4*A - 6*a^2*A*b^2 + A*b^4 + 4*a^3*b*B - 4*a*b^3*B)*x)/(a^2 + b^2)^4) - ((4*a^3*A*b - 4*a*A*b^3 - a^4*B +
 6*a^2*b^2*B - b^4*B)*Log[a*Cos[c + d*x] + b*Sin[c + d*x]])/((a^2 + b^2)^4*d) - (a^2*(A*b - a*B))/(3*b^2*(a^2
+ b^2)*d*(a + b*Tan[c + d*x])^3) + (a*(2*A*b^3 - a*(a^2 + 3*b^2)*B))/(2*b^2*(a^2 + b^2)^2*d*(a + b*Tan[c + d*x
])^2) + (3*a^2*A*b - A*b^3 - a^3*B + 3*a*b^2*B)/((a^2 + b^2)^3*d*(a + b*Tan[c + d*x]))

Rule 3610

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b
*c - a*d)*((a + b*Tan[e + f*x])^(m + 1)/(f*(m + 1)*(a^2 + b^2))), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e +
f*x])^(m + 1)*Simp[a*c + b*d - (b*c - a*d)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c
 - a*d, 0] && NeQ[a^2 + b^2, 0] && LtQ[m, -1]

Rule 3611

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c/(b*f))
*Log[RemoveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rule 3612

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c +
b*d)*(x/(a^2 + b^2)), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rule 3685

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^2*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.)
 + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[(-(B*c - A*d))*(b*c - a*d)^2*((c + d*Tan[e + f*x])^(n + 1)/(f*d^2*(n +
 1)*(c^2 + d^2))), x] + Dist[1/(d*(c^2 + d^2)), Int[(c + d*Tan[e + f*x])^(n + 1)*Simp[B*(b*c - a*d)^2 + A*d*(a
^2*c - b^2*c + 2*a*b*d) + d*(B*(a^2*c - b^2*c + 2*a*b*d) + A*(2*a*b*c - a^2*d + b^2*d))*Tan[e + f*x] + b^2*B*(
c^2 + d^2)*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 +
b^2, 0] && NeQ[c^2 + d^2, 0] && LtQ[n, -1]

Rule 3709

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f
_.)*(x_)]^2), x_Symbol] :> Simp[(A*b^2 - a*b*B + a^2*C)*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1)*(a^2 + b^2)
)), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e + f*x])^(m + 1)*Simp[b*B + a*(A - C) - (A*b - a*B - b*C)*Tan[e +
 f*x], x], x], x] /; FreeQ[{a, b, e, f, A, B, C}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0] && LtQ[m, -1] && NeQ[a^2
 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = -\frac {a^2 (A b-a B)}{3 b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))^3}+\frac {\int \frac {-a (A b-a B)+b (A b-a B) \tan (c+d x)+\left (a^2+b^2\right ) B \tan ^2(c+d x)}{(a+b \tan (c+d x))^3} \, dx}{b \left (a^2+b^2\right )} \\ & = -\frac {a^2 (A b-a B)}{3 b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))^3}+\frac {a \left (2 A b^3-a \left (a^2+3 b^2\right ) B\right )}{2 b^2 \left (a^2+b^2\right )^2 d (a+b \tan (c+d x))^2}+\frac {\int \frac {-b \left (a^2 A-A b^2+2 a b B\right )+b \left (2 a A b-a^2 B+b^2 B\right ) \tan (c+d x)}{(a+b \tan (c+d x))^2} \, dx}{b \left (a^2+b^2\right )^2} \\ & = -\frac {a^2 (A b-a B)}{3 b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))^3}+\frac {a \left (2 A b^3-a \left (a^2+3 b^2\right ) B\right )}{2 b^2 \left (a^2+b^2\right )^2 d (a+b \tan (c+d x))^2}+\frac {3 a^2 A b-A b^3-a^3 B+3 a b^2 B}{\left (a^2+b^2\right )^3 d (a+b \tan (c+d x))}+\frac {\int \frac {-b \left (a^3 A-3 a A b^2+3 a^2 b B-b^3 B\right )+b \left (3 a^2 A b-A b^3-a^3 B+3 a b^2 B\right ) \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{b \left (a^2+b^2\right )^3} \\ & = -\frac {\left (a^4 A-6 a^2 A b^2+A b^4+4 a^3 b B-4 a b^3 B\right ) x}{\left (a^2+b^2\right )^4}-\frac {a^2 (A b-a B)}{3 b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))^3}+\frac {a \left (2 A b^3-a \left (a^2+3 b^2\right ) B\right )}{2 b^2 \left (a^2+b^2\right )^2 d (a+b \tan (c+d x))^2}+\frac {3 a^2 A b-A b^3-a^3 B+3 a b^2 B}{\left (a^2+b^2\right )^3 d (a+b \tan (c+d x))}-\frac {\left (4 a^3 A b-4 a A b^3-a^4 B+6 a^2 b^2 B-b^4 B\right ) \int \frac {b-a \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{\left (a^2+b^2\right )^4} \\ & = -\frac {\left (a^4 A-6 a^2 A b^2+A b^4+4 a^3 b B-4 a b^3 B\right ) x}{\left (a^2+b^2\right )^4}-\frac {\left (4 a^3 A b-4 a A b^3-a^4 B+6 a^2 b^2 B-b^4 B\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{\left (a^2+b^2\right )^4 d}-\frac {a^2 (A b-a B)}{3 b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))^3}+\frac {a \left (2 A b^3-a \left (a^2+3 b^2\right ) B\right )}{2 b^2 \left (a^2+b^2\right )^2 d (a+b \tan (c+d x))^2}+\frac {3 a^2 A b-A b^3-a^3 B+3 a b^2 B}{\left (a^2+b^2\right )^3 d (a+b \tan (c+d x))} \\ \end{align*}

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 6.32 (sec) , antiderivative size = 411, normalized size of antiderivative = 1.57 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+b \tan (c+d x))^4} \, dx=-\frac {B \tan (c+d x)}{2 b d (a+b \tan (c+d x))^3}-\frac {\frac {2 A b+a B}{3 b d (a+b \tan (c+d x))^3}+\frac {\frac {\left (6 A b^3-6 a b^2 B\right ) \left (-\frac {i \log (i-\tan (c+d x))}{2 (a+i b)^4}+\frac {i \log (i+\tan (c+d x))}{2 (a-i b)^4}+\frac {4 a (a-b) b (a+b) \log (a+b \tan (c+d x))}{\left (a^2+b^2\right )^4}-\frac {b}{3 \left (a^2+b^2\right ) (a+b \tan (c+d x))^3}-\frac {a b}{\left (a^2+b^2\right )^2 (a+b \tan (c+d x))^2}-\frac {b \left (3 a^2-b^2\right )}{\left (a^2+b^2\right )^3 (a+b \tan (c+d x))}\right )}{b}+6 b B \left (-\frac {\log (i-\tan (c+d x))}{2 (i a-b)^3}+\frac {\log (i+\tan (c+d x))}{2 (i a+b)^3}+\frac {b \left (3 a^2-b^2\right ) \log (a+b \tan (c+d x))}{\left (a^2+b^2\right )^3}-\frac {b}{2 \left (a^2+b^2\right ) (a+b \tan (c+d x))^2}-\frac {2 a b}{\left (a^2+b^2\right )^2 (a+b \tan (c+d x))}\right )}{3 b d}}{2 b} \]

[In]

Integrate[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + b*Tan[c + d*x])^4,x]

[Out]

-1/2*(B*Tan[c + d*x])/(b*d*(a + b*Tan[c + d*x])^3) - ((2*A*b + a*B)/(3*b*d*(a + b*Tan[c + d*x])^3) + (((6*A*b^
3 - 6*a*b^2*B)*(((-1/2*I)*Log[I - Tan[c + d*x]])/(a + I*b)^4 + ((I/2)*Log[I + Tan[c + d*x]])/(a - I*b)^4 + (4*
a*(a - b)*b*(a + b)*Log[a + b*Tan[c + d*x]])/(a^2 + b^2)^4 - b/(3*(a^2 + b^2)*(a + b*Tan[c + d*x])^3) - (a*b)/
((a^2 + b^2)^2*(a + b*Tan[c + d*x])^2) - (b*(3*a^2 - b^2))/((a^2 + b^2)^3*(a + b*Tan[c + d*x]))))/b + 6*b*B*(-
1/2*Log[I - Tan[c + d*x]]/(I*a - b)^3 + Log[I + Tan[c + d*x]]/(2*(I*a + b)^3) + (b*(3*a^2 - b^2)*Log[a + b*Tan
[c + d*x]])/(a^2 + b^2)^3 - b/(2*(a^2 + b^2)*(a + b*Tan[c + d*x])^2) - (2*a*b)/((a^2 + b^2)^2*(a + b*Tan[c + d
*x]))))/(3*b*d))/(2*b)

Maple [A] (verified)

Time = 0.21 (sec) , antiderivative size = 301, normalized size of antiderivative = 1.15

method result size
derivativedivides \(\frac {\frac {\frac {\left (4 A \,a^{3} b -4 A a \,b^{3}-B \,a^{4}+6 B \,a^{2} b^{2}-B \,b^{4}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-A \,a^{4}+6 A \,a^{2} b^{2}-A \,b^{4}-4 B \,a^{3} b +4 B a \,b^{3}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{4}}-\frac {a^{2} \left (A b -B a \right )}{3 b^{2} \left (a^{2}+b^{2}\right ) \left (a +b \tan \left (d x +c \right )\right )^{3}}+\frac {3 A \,a^{2} b -A \,b^{3}-B \,a^{3}+3 B a \,b^{2}}{\left (a^{2}+b^{2}\right )^{3} \left (a +b \tan \left (d x +c \right )\right )}-\frac {\left (4 A \,a^{3} b -4 A a \,b^{3}-B \,a^{4}+6 B \,a^{2} b^{2}-B \,b^{4}\right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{4}}+\frac {a \left (2 A \,b^{3}-B \,a^{3}-3 B a \,b^{2}\right )}{2 \left (a^{2}+b^{2}\right )^{2} b^{2} \left (a +b \tan \left (d x +c \right )\right )^{2}}}{d}\) \(301\)
default \(\frac {\frac {\frac {\left (4 A \,a^{3} b -4 A a \,b^{3}-B \,a^{4}+6 B \,a^{2} b^{2}-B \,b^{4}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-A \,a^{4}+6 A \,a^{2} b^{2}-A \,b^{4}-4 B \,a^{3} b +4 B a \,b^{3}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{4}}-\frac {a^{2} \left (A b -B a \right )}{3 b^{2} \left (a^{2}+b^{2}\right ) \left (a +b \tan \left (d x +c \right )\right )^{3}}+\frac {3 A \,a^{2} b -A \,b^{3}-B \,a^{3}+3 B a \,b^{2}}{\left (a^{2}+b^{2}\right )^{3} \left (a +b \tan \left (d x +c \right )\right )}-\frac {\left (4 A \,a^{3} b -4 A a \,b^{3}-B \,a^{4}+6 B \,a^{2} b^{2}-B \,b^{4}\right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{4}}+\frac {a \left (2 A \,b^{3}-B \,a^{3}-3 B a \,b^{2}\right )}{2 \left (a^{2}+b^{2}\right )^{2} b^{2} \left (a +b \tan \left (d x +c \right )\right )^{2}}}{d}\) \(301\)
norman \(\frac {-\frac {\left (8 A \,a^{3} b^{3}-B \,a^{6}-6 B \,a^{4} b^{2}+3 B \,a^{2} b^{4}\right ) \left (\tan ^{2}\left (d x +c \right )\right )}{2 a d \left (a^{6}+3 a^{4} b^{2}+3 a^{2} b^{4}+b^{6}\right )}-\frac {a \left (A \,a^{5}-3 A \,a^{3} b^{2}+3 B \,a^{4} b -B \,a^{2} b^{3}\right )}{3 d b \left (a^{6}+3 a^{4} b^{2}+3 a^{2} b^{4}+b^{6}\right )}-\frac {\left (A \,a^{4}-6 A \,a^{2} b^{2}+A \,b^{4}+4 B \,a^{3} b -4 B a \,b^{3}\right ) a^{3} x}{\left (a^{6}+3 a^{4} b^{2}+3 a^{2} b^{4}+b^{6}\right ) \left (a^{2}+b^{2}\right )}-\frac {b \left (14 A \,a^{3} b^{3}-2 A a \,b^{5}-B \,a^{6}-8 B \,a^{4} b^{2}+9 B \,a^{2} b^{4}\right ) \left (\tan ^{3}\left (d x +c \right )\right )}{6 d \,a^{2} \left (a^{6}+3 a^{4} b^{2}+3 a^{2} b^{4}+b^{6}\right )}-\frac {b^{3} \left (A \,a^{4}-6 A \,a^{2} b^{2}+A \,b^{4}+4 B \,a^{3} b -4 B a \,b^{3}\right ) x \left (\tan ^{3}\left (d x +c \right )\right )}{\left (a^{6}+3 a^{4} b^{2}+3 a^{2} b^{4}+b^{6}\right ) \left (a^{2}+b^{2}\right )}-\frac {3 b \left (A \,a^{4}-6 A \,a^{2} b^{2}+A \,b^{4}+4 B \,a^{3} b -4 B a \,b^{3}\right ) a^{2} x \tan \left (d x +c \right )}{\left (a^{6}+3 a^{4} b^{2}+3 a^{2} b^{4}+b^{6}\right ) \left (a^{2}+b^{2}\right )}-\frac {3 b^{2} \left (A \,a^{4}-6 A \,a^{2} b^{2}+A \,b^{4}+4 B \,a^{3} b -4 B a \,b^{3}\right ) a x \left (\tan ^{2}\left (d x +c \right )\right )}{\left (a^{6}+3 a^{4} b^{2}+3 a^{2} b^{4}+b^{6}\right ) \left (a^{2}+b^{2}\right )}}{\left (a +b \tan \left (d x +c \right )\right )^{3}}+\frac {\left (4 A \,a^{3} b -4 A a \,b^{3}-B \,a^{4}+6 B \,a^{2} b^{2}-B \,b^{4}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d \left (a^{8}+4 a^{6} b^{2}+6 a^{4} b^{4}+4 a^{2} b^{6}+b^{8}\right )}-\frac {\left (4 A \,a^{3} b -4 A a \,b^{3}-B \,a^{4}+6 B \,a^{2} b^{2}-B \,b^{4}\right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{d \left (a^{8}+4 a^{6} b^{2}+6 a^{4} b^{4}+4 a^{2} b^{6}+b^{8}\right )}\) \(729\)
risch \(\text {Expression too large to display}\) \(1422\)
parallelrisch \(\text {Expression too large to display}\) \(1654\)

[In]

int(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+b*tan(d*x+c))^4,x,method=_RETURNVERBOSE)

[Out]

1/d*(1/(a^2+b^2)^4*(1/2*(4*A*a^3*b-4*A*a*b^3-B*a^4+6*B*a^2*b^2-B*b^4)*ln(1+tan(d*x+c)^2)+(-A*a^4+6*A*a^2*b^2-A
*b^4-4*B*a^3*b+4*B*a*b^3)*arctan(tan(d*x+c)))-1/3*a^2*(A*b-B*a)/b^2/(a^2+b^2)/(a+b*tan(d*x+c))^3+(3*A*a^2*b-A*
b^3-B*a^3+3*B*a*b^2)/(a^2+b^2)^3/(a+b*tan(d*x+c))-(4*A*a^3*b-4*A*a*b^3-B*a^4+6*B*a^2*b^2-B*b^4)/(a^2+b^2)^4*ln
(a+b*tan(d*x+c))+1/2*a*(2*A*b^3-B*a^3-3*B*a*b^2)/(a^2+b^2)^2/b^2/(a+b*tan(d*x+c))^2)

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 836 vs. \(2 (253) = 506\).

Time = 0.33 (sec) , antiderivative size = 836, normalized size of antiderivative = 3.20 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+b \tan (c+d x))^4} \, dx=\frac {3 \, B a^{7} - 12 \, A a^{6} b - 30 \, B a^{5} b^{2} + 30 \, A a^{4} b^{3} + 11 \, B a^{3} b^{4} - 2 \, A a^{2} b^{5} + {\left (B a^{6} b + 2 \, A a^{5} b^{2} + 18 \, B a^{4} b^{3} - 30 \, A a^{3} b^{4} - 27 \, B a^{2} b^{5} + 12 \, A a b^{6} - 6 \, {\left (A a^{4} b^{3} + 4 \, B a^{3} b^{4} - 6 \, A a^{2} b^{5} - 4 \, B a b^{6} + A b^{7}\right )} d x\right )} \tan \left (d x + c\right )^{3} - 6 \, {\left (A a^{7} + 4 \, B a^{6} b - 6 \, A a^{5} b^{2} - 4 \, B a^{4} b^{3} + A a^{3} b^{4}\right )} d x + 3 \, {\left (B a^{7} + 2 \, A a^{6} b + 16 \, B a^{5} b^{2} - 24 \, A a^{4} b^{3} - 23 \, B a^{3} b^{4} + 16 \, A a^{2} b^{5} + 6 \, B a b^{6} - 2 \, A b^{7} - 6 \, {\left (A a^{5} b^{2} + 4 \, B a^{4} b^{3} - 6 \, A a^{3} b^{4} - 4 \, B a^{2} b^{5} + A a b^{6}\right )} d x\right )} \tan \left (d x + c\right )^{2} + 3 \, {\left (B a^{7} - 4 \, A a^{6} b - 6 \, B a^{5} b^{2} + 4 \, A a^{4} b^{3} + B a^{3} b^{4} + {\left (B a^{4} b^{3} - 4 \, A a^{3} b^{4} - 6 \, B a^{2} b^{5} + 4 \, A a b^{6} + B b^{7}\right )} \tan \left (d x + c\right )^{3} + 3 \, {\left (B a^{5} b^{2} - 4 \, A a^{4} b^{3} - 6 \, B a^{3} b^{4} + 4 \, A a^{2} b^{5} + B a b^{6}\right )} \tan \left (d x + c\right )^{2} + 3 \, {\left (B a^{6} b - 4 \, A a^{5} b^{2} - 6 \, B a^{4} b^{3} + 4 \, A a^{3} b^{4} + B a^{2} b^{5}\right )} \tan \left (d x + c\right )\right )} \log \left (\frac {b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) + 3 \, {\left (2 \, A a^{7} + 9 \, B a^{6} b - 16 \, A a^{5} b^{2} - 26 \, B a^{4} b^{3} + 24 \, A a^{3} b^{4} + 9 \, B a^{2} b^{5} - 2 \, A a b^{6} - 6 \, {\left (A a^{6} b + 4 \, B a^{5} b^{2} - 6 \, A a^{4} b^{3} - 4 \, B a^{3} b^{4} + A a^{2} b^{5}\right )} d x\right )} \tan \left (d x + c\right )}{6 \, {\left ({\left (a^{8} b^{3} + 4 \, a^{6} b^{5} + 6 \, a^{4} b^{7} + 4 \, a^{2} b^{9} + b^{11}\right )} d \tan \left (d x + c\right )^{3} + 3 \, {\left (a^{9} b^{2} + 4 \, a^{7} b^{4} + 6 \, a^{5} b^{6} + 4 \, a^{3} b^{8} + a b^{10}\right )} d \tan \left (d x + c\right )^{2} + 3 \, {\left (a^{10} b + 4 \, a^{8} b^{3} + 6 \, a^{6} b^{5} + 4 \, a^{4} b^{7} + a^{2} b^{9}\right )} d \tan \left (d x + c\right ) + {\left (a^{11} + 4 \, a^{9} b^{2} + 6 \, a^{7} b^{4} + 4 \, a^{5} b^{6} + a^{3} b^{8}\right )} d\right )}} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+b*tan(d*x+c))^4,x, algorithm="fricas")

[Out]

1/6*(3*B*a^7 - 12*A*a^6*b - 30*B*a^5*b^2 + 30*A*a^4*b^3 + 11*B*a^3*b^4 - 2*A*a^2*b^5 + (B*a^6*b + 2*A*a^5*b^2
+ 18*B*a^4*b^3 - 30*A*a^3*b^4 - 27*B*a^2*b^5 + 12*A*a*b^6 - 6*(A*a^4*b^3 + 4*B*a^3*b^4 - 6*A*a^2*b^5 - 4*B*a*b
^6 + A*b^7)*d*x)*tan(d*x + c)^3 - 6*(A*a^7 + 4*B*a^6*b - 6*A*a^5*b^2 - 4*B*a^4*b^3 + A*a^3*b^4)*d*x + 3*(B*a^7
 + 2*A*a^6*b + 16*B*a^5*b^2 - 24*A*a^4*b^3 - 23*B*a^3*b^4 + 16*A*a^2*b^5 + 6*B*a*b^6 - 2*A*b^7 - 6*(A*a^5*b^2
+ 4*B*a^4*b^3 - 6*A*a^3*b^4 - 4*B*a^2*b^5 + A*a*b^6)*d*x)*tan(d*x + c)^2 + 3*(B*a^7 - 4*A*a^6*b - 6*B*a^5*b^2
+ 4*A*a^4*b^3 + B*a^3*b^4 + (B*a^4*b^3 - 4*A*a^3*b^4 - 6*B*a^2*b^5 + 4*A*a*b^6 + B*b^7)*tan(d*x + c)^3 + 3*(B*
a^5*b^2 - 4*A*a^4*b^3 - 6*B*a^3*b^4 + 4*A*a^2*b^5 + B*a*b^6)*tan(d*x + c)^2 + 3*(B*a^6*b - 4*A*a^5*b^2 - 6*B*a
^4*b^3 + 4*A*a^3*b^4 + B*a^2*b^5)*tan(d*x + c))*log((b^2*tan(d*x + c)^2 + 2*a*b*tan(d*x + c) + a^2)/(tan(d*x +
 c)^2 + 1)) + 3*(2*A*a^7 + 9*B*a^6*b - 16*A*a^5*b^2 - 26*B*a^4*b^3 + 24*A*a^3*b^4 + 9*B*a^2*b^5 - 2*A*a*b^6 -
6*(A*a^6*b + 4*B*a^5*b^2 - 6*A*a^4*b^3 - 4*B*a^3*b^4 + A*a^2*b^5)*d*x)*tan(d*x + c))/((a^8*b^3 + 4*a^6*b^5 + 6
*a^4*b^7 + 4*a^2*b^9 + b^11)*d*tan(d*x + c)^3 + 3*(a^9*b^2 + 4*a^7*b^4 + 6*a^5*b^6 + 4*a^3*b^8 + a*b^10)*d*tan
(d*x + c)^2 + 3*(a^10*b + 4*a^8*b^3 + 6*a^6*b^5 + 4*a^4*b^7 + a^2*b^9)*d*tan(d*x + c) + (a^11 + 4*a^9*b^2 + 6*
a^7*b^4 + 4*a^5*b^6 + a^3*b^8)*d)

Sympy [F(-2)]

Exception generated. \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+b \tan (c+d x))^4} \, dx=\text {Exception raised: AttributeError} \]

[In]

integrate(tan(d*x+c)**2*(A+B*tan(d*x+c))/(a+b*tan(d*x+c))**4,x)

[Out]

Exception raised: AttributeError >> 'NoneType' object has no attribute 'primitive'

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 526 vs. \(2 (253) = 506\).

Time = 0.40 (sec) , antiderivative size = 526, normalized size of antiderivative = 2.02 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+b \tan (c+d x))^4} \, dx=-\frac {\frac {6 \, {\left (A a^{4} + 4 \, B a^{3} b - 6 \, A a^{2} b^{2} - 4 \, B a b^{3} + A b^{4}\right )} {\left (d x + c\right )}}{a^{8} + 4 \, a^{6} b^{2} + 6 \, a^{4} b^{4} + 4 \, a^{2} b^{6} + b^{8}} - \frac {6 \, {\left (B a^{4} - 4 \, A a^{3} b - 6 \, B a^{2} b^{2} + 4 \, A a b^{3} + B b^{4}\right )} \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{8} + 4 \, a^{6} b^{2} + 6 \, a^{4} b^{4} + 4 \, a^{2} b^{6} + b^{8}} + \frac {3 \, {\left (B a^{4} - 4 \, A a^{3} b - 6 \, B a^{2} b^{2} + 4 \, A a b^{3} + B b^{4}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{8} + 4 \, a^{6} b^{2} + 6 \, a^{4} b^{4} + 4 \, a^{2} b^{6} + b^{8}} + \frac {B a^{7} + 2 \, A a^{6} b + 14 \, B a^{5} b^{2} - 20 \, A a^{4} b^{3} - 11 \, B a^{3} b^{4} + 2 \, A a^{2} b^{5} + 6 \, {\left (B a^{3} b^{4} - 3 \, A a^{2} b^{5} - 3 \, B a b^{6} + A b^{7}\right )} \tan \left (d x + c\right )^{2} + 3 \, {\left (B a^{6} b + 8 \, B a^{4} b^{3} - 14 \, A a^{3} b^{4} - 9 \, B a^{2} b^{5} + 2 \, A a b^{6}\right )} \tan \left (d x + c\right )}{a^{9} b^{2} + 3 \, a^{7} b^{4} + 3 \, a^{5} b^{6} + a^{3} b^{8} + {\left (a^{6} b^{5} + 3 \, a^{4} b^{7} + 3 \, a^{2} b^{9} + b^{11}\right )} \tan \left (d x + c\right )^{3} + 3 \, {\left (a^{7} b^{4} + 3 \, a^{5} b^{6} + 3 \, a^{3} b^{8} + a b^{10}\right )} \tan \left (d x + c\right )^{2} + 3 \, {\left (a^{8} b^{3} + 3 \, a^{6} b^{5} + 3 \, a^{4} b^{7} + a^{2} b^{9}\right )} \tan \left (d x + c\right )}}{6 \, d} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+b*tan(d*x+c))^4,x, algorithm="maxima")

[Out]

-1/6*(6*(A*a^4 + 4*B*a^3*b - 6*A*a^2*b^2 - 4*B*a*b^3 + A*b^4)*(d*x + c)/(a^8 + 4*a^6*b^2 + 6*a^4*b^4 + 4*a^2*b
^6 + b^8) - 6*(B*a^4 - 4*A*a^3*b - 6*B*a^2*b^2 + 4*A*a*b^3 + B*b^4)*log(b*tan(d*x + c) + a)/(a^8 + 4*a^6*b^2 +
 6*a^4*b^4 + 4*a^2*b^6 + b^8) + 3*(B*a^4 - 4*A*a^3*b - 6*B*a^2*b^2 + 4*A*a*b^3 + B*b^4)*log(tan(d*x + c)^2 + 1
)/(a^8 + 4*a^6*b^2 + 6*a^4*b^4 + 4*a^2*b^6 + b^8) + (B*a^7 + 2*A*a^6*b + 14*B*a^5*b^2 - 20*A*a^4*b^3 - 11*B*a^
3*b^4 + 2*A*a^2*b^5 + 6*(B*a^3*b^4 - 3*A*a^2*b^5 - 3*B*a*b^6 + A*b^7)*tan(d*x + c)^2 + 3*(B*a^6*b + 8*B*a^4*b^
3 - 14*A*a^3*b^4 - 9*B*a^2*b^5 + 2*A*a*b^6)*tan(d*x + c))/(a^9*b^2 + 3*a^7*b^4 + 3*a^5*b^6 + a^3*b^8 + (a^6*b^
5 + 3*a^4*b^7 + 3*a^2*b^9 + b^11)*tan(d*x + c)^3 + 3*(a^7*b^4 + 3*a^5*b^6 + 3*a^3*b^8 + a*b^10)*tan(d*x + c)^2
 + 3*(a^8*b^3 + 3*a^6*b^5 + 3*a^4*b^7 + a^2*b^9)*tan(d*x + c)))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 632 vs. \(2 (253) = 506\).

Time = 0.83 (sec) , antiderivative size = 632, normalized size of antiderivative = 2.42 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+b \tan (c+d x))^4} \, dx=-\frac {\frac {6 \, {\left (A a^{4} + 4 \, B a^{3} b - 6 \, A a^{2} b^{2} - 4 \, B a b^{3} + A b^{4}\right )} {\left (d x + c\right )}}{a^{8} + 4 \, a^{6} b^{2} + 6 \, a^{4} b^{4} + 4 \, a^{2} b^{6} + b^{8}} + \frac {3 \, {\left (B a^{4} - 4 \, A a^{3} b - 6 \, B a^{2} b^{2} + 4 \, A a b^{3} + B b^{4}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{8} + 4 \, a^{6} b^{2} + 6 \, a^{4} b^{4} + 4 \, a^{2} b^{6} + b^{8}} - \frac {6 \, {\left (B a^{4} b - 4 \, A a^{3} b^{2} - 6 \, B a^{2} b^{3} + 4 \, A a b^{4} + B b^{5}\right )} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{8} b + 4 \, a^{6} b^{3} + 6 \, a^{4} b^{5} + 4 \, a^{2} b^{7} + b^{9}} + \frac {11 \, B a^{4} b^{5} \tan \left (d x + c\right )^{3} - 44 \, A a^{3} b^{6} \tan \left (d x + c\right )^{3} - 66 \, B a^{2} b^{7} \tan \left (d x + c\right )^{3} + 44 \, A a b^{8} \tan \left (d x + c\right )^{3} + 11 \, B b^{9} \tan \left (d x + c\right )^{3} + 39 \, B a^{5} b^{4} \tan \left (d x + c\right )^{2} - 150 \, A a^{4} b^{5} \tan \left (d x + c\right )^{2} - 210 \, B a^{3} b^{6} \tan \left (d x + c\right )^{2} + 120 \, A a^{2} b^{7} \tan \left (d x + c\right )^{2} + 15 \, B a b^{8} \tan \left (d x + c\right )^{2} + 6 \, A b^{9} \tan \left (d x + c\right )^{2} + 3 \, B a^{8} b \tan \left (d x + c\right ) + 60 \, B a^{6} b^{3} \tan \left (d x + c\right ) - 174 \, A a^{5} b^{4} \tan \left (d x + c\right ) - 201 \, B a^{4} b^{5} \tan \left (d x + c\right ) + 96 \, A a^{3} b^{6} \tan \left (d x + c\right ) + 6 \, B a^{2} b^{7} \tan \left (d x + c\right ) + 6 \, A a b^{8} \tan \left (d x + c\right ) + B a^{9} + 2 \, A a^{8} b + 26 \, B a^{7} b^{2} - 62 \, A a^{6} b^{3} - 63 \, B a^{5} b^{4} + 26 \, A a^{4} b^{5} + 2 \, A a^{2} b^{7}}{{\left (a^{8} b^{2} + 4 \, a^{6} b^{4} + 6 \, a^{4} b^{6} + 4 \, a^{2} b^{8} + b^{10}\right )} {\left (b \tan \left (d x + c\right ) + a\right )}^{3}}}{6 \, d} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+b*tan(d*x+c))^4,x, algorithm="giac")

[Out]

-1/6*(6*(A*a^4 + 4*B*a^3*b - 6*A*a^2*b^2 - 4*B*a*b^3 + A*b^4)*(d*x + c)/(a^8 + 4*a^6*b^2 + 6*a^4*b^4 + 4*a^2*b
^6 + b^8) + 3*(B*a^4 - 4*A*a^3*b - 6*B*a^2*b^2 + 4*A*a*b^3 + B*b^4)*log(tan(d*x + c)^2 + 1)/(a^8 + 4*a^6*b^2 +
 6*a^4*b^4 + 4*a^2*b^6 + b^8) - 6*(B*a^4*b - 4*A*a^3*b^2 - 6*B*a^2*b^3 + 4*A*a*b^4 + B*b^5)*log(abs(b*tan(d*x
+ c) + a))/(a^8*b + 4*a^6*b^3 + 6*a^4*b^5 + 4*a^2*b^7 + b^9) + (11*B*a^4*b^5*tan(d*x + c)^3 - 44*A*a^3*b^6*tan
(d*x + c)^3 - 66*B*a^2*b^7*tan(d*x + c)^3 + 44*A*a*b^8*tan(d*x + c)^3 + 11*B*b^9*tan(d*x + c)^3 + 39*B*a^5*b^4
*tan(d*x + c)^2 - 150*A*a^4*b^5*tan(d*x + c)^2 - 210*B*a^3*b^6*tan(d*x + c)^2 + 120*A*a^2*b^7*tan(d*x + c)^2 +
 15*B*a*b^8*tan(d*x + c)^2 + 6*A*b^9*tan(d*x + c)^2 + 3*B*a^8*b*tan(d*x + c) + 60*B*a^6*b^3*tan(d*x + c) - 174
*A*a^5*b^4*tan(d*x + c) - 201*B*a^4*b^5*tan(d*x + c) + 96*A*a^3*b^6*tan(d*x + c) + 6*B*a^2*b^7*tan(d*x + c) +
6*A*a*b^8*tan(d*x + c) + B*a^9 + 2*A*a^8*b + 26*B*a^7*b^2 - 62*A*a^6*b^3 - 63*B*a^5*b^4 + 26*A*a^4*b^5 + 2*A*a
^2*b^7)/((a^8*b^2 + 4*a^6*b^4 + 6*a^4*b^6 + 4*a^2*b^8 + b^10)*(b*tan(d*x + c) + a)^3))/d

Mupad [B] (verification not implemented)

Time = 7.87 (sec) , antiderivative size = 446, normalized size of antiderivative = 1.71 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+b \tan (c+d x))^4} \, dx=\frac {\ln \left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )\,\left (\frac {B}{{\left (a^2+b^2\right )}^2}-\frac {4\,b\,\left (A\,a+2\,B\,b\right )}{{\left (a^2+b^2\right )}^3}+\frac {8\,b^3\,\left (A\,a+B\,b\right )}{{\left (a^2+b^2\right )}^4}\right )}{d}-\frac {\frac {{\mathrm {tan}\left (c+d\,x\right )}^2\,\left (B\,a^3\,b^2-3\,A\,a^2\,b^3-3\,B\,a\,b^4+A\,b^5\right )}{a^6+3\,a^4\,b^2+3\,a^2\,b^4+b^6}+\frac {a\,\left (B\,a^6+2\,A\,a^5\,b+14\,B\,a^4\,b^2-20\,A\,a^3\,b^3-11\,B\,a^2\,b^4+2\,A\,a\,b^5\right )}{6\,b^2\,\left (a^6+3\,a^4\,b^2+3\,a^2\,b^4+b^6\right )}+\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (B\,a^6+8\,B\,a^4\,b^2-14\,A\,a^3\,b^3-9\,B\,a^2\,b^4+2\,A\,a\,b^5\right )}{2\,b\,\left (a^6+3\,a^4\,b^2+3\,a^2\,b^4+b^6\right )}}{d\,\left (a^3+3\,a^2\,b\,\mathrm {tan}\left (c+d\,x\right )+3\,a\,b^2\,{\mathrm {tan}\left (c+d\,x\right )}^2+b^3\,{\mathrm {tan}\left (c+d\,x\right )}^3\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (A+B\,1{}\mathrm {i}\right )}{2\,d\,\left (a^4\,1{}\mathrm {i}-4\,a^3\,b-a^2\,b^2\,6{}\mathrm {i}+4\,a\,b^3+b^4\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B+A\,1{}\mathrm {i}\right )}{2\,d\,\left (a^4-a^3\,b\,4{}\mathrm {i}-6\,a^2\,b^2+a\,b^3\,4{}\mathrm {i}+b^4\right )} \]

[In]

int((tan(c + d*x)^2*(A + B*tan(c + d*x)))/(a + b*tan(c + d*x))^4,x)

[Out]

(log(a + b*tan(c + d*x))*(B/(a^2 + b^2)^2 - (4*b*(A*a + 2*B*b))/(a^2 + b^2)^3 + (8*b^3*(A*a + B*b))/(a^2 + b^2
)^4))/d - ((tan(c + d*x)^2*(A*b^5 - 3*A*a^2*b^3 + B*a^3*b^2 - 3*B*a*b^4))/(a^6 + b^6 + 3*a^2*b^4 + 3*a^4*b^2)
+ (a*(B*a^6 - 20*A*a^3*b^3 - 11*B*a^2*b^4 + 14*B*a^4*b^2 + 2*A*a*b^5 + 2*A*a^5*b))/(6*b^2*(a^6 + b^6 + 3*a^2*b
^4 + 3*a^4*b^2)) + (tan(c + d*x)*(B*a^6 - 14*A*a^3*b^3 - 9*B*a^2*b^4 + 8*B*a^4*b^2 + 2*A*a*b^5))/(2*b*(a^6 + b
^6 + 3*a^2*b^4 + 3*a^4*b^2)))/(d*(a^3 + b^3*tan(c + d*x)^3 + 3*a*b^2*tan(c + d*x)^2 + 3*a^2*b*tan(c + d*x))) -
 (log(tan(c + d*x) - 1i)*(A + B*1i))/(2*d*(4*a*b^3 - 4*a^3*b + a^4*1i + b^4*1i - a^2*b^2*6i)) - (log(tan(c + d
*x) + 1i)*(A*1i + B))/(2*d*(a*b^3*4i - a^3*b*4i + a^4 + b^4 - 6*a^2*b^2))